﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Buccaneer;
using CustomControls;

namespace Buccaneer
{
    public partial class AddressBar
    {
        public void AddSeparator(string txt)
        {
            BitmapButton addval;
            addval = new BitmapButton();
            addval.LoadImages("addressbarSeparator");
            addval.Size = addval.ImageNormal.Size;
            addval.Location = new Point
            (
                (int)(
                    this.leftImg.Width +
                    g.MeasureString(this.Text, Options.Font).Width +
                    addval.ImageNormal.Width * this.separators.Count
                ),
                2
            );
            this.separators.Add(addval);
        }

        public void UpdatePath()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new updatePathDelegate(UpdatePath));
            }
            else
            {
                foreach (string s in pathParts)
                {
                    if (s != "")
                        this.AddSeparator(s);
                }
                this.Controls.Clear();
                this.Controls.AddRange(this.separators.ToArray());
                this.Controls.Add(this.textBox);
                this.textBox.Text = this.pathParts[this.pathParts.Count - 1];
            }
        }
    }

    delegate void updatePathDelegate();
}
